package com.mowwang.file;

import java.io.File;
import java.io.FileWriter;
import java.io.IOException;

public class HelloWord {
    public static void main(String[] args) {
        //创建一个文件
        File file =new File("a.txt");
        FileWriter fileWriter=null;
        try {//创建一个输出流对象
           fileWriter=new FileWriter(file);
            //把内容写入文件
            fileWriter.write("HelloWord");
        } catch (IOException e) {
            e.printStackTrace();
        }finally {
            if (fileWriter!=null) {
                try {
                    //关闭流
                    fileWriter.close();
                } catch (IOException e) {
                    e.printStackTrace();
                }
            }
        }
    }
}
